import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] cost = new int[n];
        for(int i=0;i<n;i++) {
            cost[i] = in.nextInt();
        }
        //动态规划dp[i]：从初始位置到i的最小花费
        int[] dp = new int[n+1];
        dp[0] = dp[1] = 0;
        for(int i=2;i<=n;i++) {
            dp[i] = Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
        }
        System.out.print(dp[n]);
    }
}